import type { Article } from '@/types/article'
import { request } from '@/utils/request'

export const getArticleList = (
  pageNum: number,
  pageSize: number,
  categoryId?: number,
  state?: '已发布' | '草稿'
) =>
  request<{
    total: number
    items: Article[]
  }>('/article', 'GET', {
    pageNum,
    pageSize,
    categoryId,
    state
  })

export const add = (article: Article) => request('/article', 'POST', article)

export const update = (article: Article) => request('/article', 'PUT', article)

export const deleteArticle = (id: number) =>
  request('/article', 'DELETE', { id })
